Intention Action List
This section provides a complete list of Intention Actions available in IntelliJ IDEA.




General Intention Actions

  • 'Add Method Body' Add default method body for the non-abstract method without body
  • 'Add on-demand/single static imports' Add import statement for static classes and class members (Java SDK 1.5)
  • 'Add @Override modifier' Add @Override if there is an overridden method in your code (Java SDK 1.5)
  • 'Add return statement' Add 'return default value' statement into the end of the method with missing return statement
  • 'Add type cast' Insert cast to required type in assignment/return/variable initializer/switch selector/array initializer/case statements with incompatible types involved
  • 'Adjust package name' Change a package name to reflect Java file path
  • 'Delete catch' Delete unused/redundant catch clause for try statement
  • 'Implement methods' Implement methods for the class
  • 'Fix Method return' Change method return type according to return statement type or overridden method return type
  • 'Fix method throws' Adjust method throws list according to overridden method throws list
  • 'Move catch up' Move catch clause for try statement up to avoid 'exception has already been caught' message (E.g. move catch (IOException) before catch (Exception))
  • 'Move class to separate file' Move public top-level class to file with corresponding name (className.java)
  • 'Move to package' Move file containing wrong package statement to corresponding package
  • 'Must be final fix' Correct problem when accessing non-final variable from inside inner class: whether 1) to a make variable offended final or 2) to introduce a new final variable, copy there an original variable value and to use a new final variable inside an inner class or 3) Transform a variable into a final one-element array and use its first element in an inner class
  • 'Optimize imports' Invoke 'optimize imports' action when unused import package statements detected
  • 'Remove redundant cast' Remove cast from expression when it is not necessary
  • 'Super method return fix' Change super methods return type according to overriding method return type
  • 'Surround with try catch' Surround selected statements with try/catch statement, generating corresponding catch blocks
  • 'Variable type fix' Change variable type in declaration when assignment/initializer with incompatible type detected
  • 'Add exception to throws' Add unhandled exception to the enclosing method throws list
  • 'Create field from parameter' Create class field based on the unused constructor parameter
  • 'Create class from new' Create class based on the new expression usage pattern
  • 'Create class from usage' Create class based on its usage pattern
  • 'Create constructor from new' Create a constructor for existing class based on the new expression usage pattern
  • 'Create field from usage' Create new field based on its usage pattern
  • 'Create local from usage' Create new local variable based on its usage pattern
  • 'Create parameter from usage' Create new method parameter based on its usage pattern
  • 'Create method from usage' Create new method based on its usage pattern
  • 'Create getter/setter from usage' Create new accessor based on its usage pattern
  • 'Implement abstract method' Implement a selected abstract method in corresponding class(es)
  • 'Rename Reference' Rename all usages of the unresolved reference to point to the most appropriate variable/class/method in given context.
  • 'Invert if condition' Swap 'then' and 'else' branches in if statement and invert its condition
  • 'Split declaration' Convert variable declaration with initializer into blank variable declaration with the following assignment/Convert single-line declaration of several variables into separate declarations
  • 'Split if action' Convert if statement containing ORed (||) or ANDed (&&) expressions into two if statements
  • 'Add exception to catch' Add catch clause for unhandled exception to the existing try statement
  • 'Implement interface/abstract class' Create class implementing interface/abstract class selected
  • 'Fetch external resource' Fetch external resource referenced from XML file
  • 'Ignore external resource' Ignore subsequent external resource references from XML file
Quick-fixes
  • Make an abstract class with no abstract methods declared non abstract when trying to instantiate
  • Make class with abstract methods declared abstract
  • Make class not final when trying to inherit from it
  • Make top-level class not public when declared in a file with wrong name
  • Make static field/method/class initializer declared in inner class not static
  • Make inner class with static field/method/class initializer declared static
  • Make final variable not final when trying to assign value to adjust method access level (public/package local/protected) according to overridden method level
  • Make final super method not final when trying to override
  • Make method abstract when a body is missing
  • Make overridden method (not)static when overriding method is (not)static
  • Make overriding method (not)static when overridden method is (not)static
  • Make field/method/class protected/package local/public when trying to access from different access level context
  • Delete modifier conflicting with other modifier (e.g. abstract final)
  • Delete not allowed modifier (e.g. private local class)
  • Make field/method/class static when accessing from the static context



Intention Actions in EJBs

  • for EJB Interface (including EJB Remote, Local, Remote Home, Local Home)
    • make interface not final
    • make interface extend corresponding javax.ejb.XXX interface (EJBHome/EJBLocalHome/EJBObject/EJBLocalObject)
  • for EJB Remote-involved class (including EJB Remote Interface, Remote Home interface)
    • make method throw java.rmi.RemoteException
  • for EJB Local-involved class (including EJB Local Interface, Local Home interface)
    • make method not throw java.rmi.RemoteException
  • for EJB Home (including Remote Home, Local Home)
    • add create method
    • add findByPrimaryKey to EntityBean Home
    • make findByPrimaryKey method return corresponding component interface
    • make create method throw CreateException
    • make create method return corresponding component interface
    • make finder method throw FinderException
    • make finder method return component interface or Collection or Enumeration
  • for EJB Local interface
    • make CMR field getter return corresponding EJB local interface
    • make CMR field setter receive corresponding EJB local interface
  • for EJB Class
    • make class implement corresponding javax.ejb.*Bean interface (SessionBean/EntityBean/MessageDrivenBean)
    • make class public
    • make class not final
    • make EB CMP 2.0 class abstract, make all other not abstract
    • create public no-args constructor
    • make MB class implement javax.jms.MessageListener
    • create corresponding ejbPostCreateXXX() method for existing ejbCreateXXX() in EB
    • create corresponding ejbCreateXXX() method for existing ejbPostCreateXXX()
    • make create method public
    • make create method not final
    • make create method not abstract
    • make create method throw CreateException
    • make create method return PK (for EB) or void
    • create CMP/CMR field accessors for CMP EB
    • make CMP/CMR field accessors abstract (not abstract for CMP 1.x)
    • make CMP/CMR field getter return type which corresponding setter receives
    • make CMP/CMR field setter receive type which corresponding getter returns
    • make CMR field getter return corresponding EJB local interface/Collection/Set
    • make CMR field setter receive corresponding EJB local interface/Collection/Set
    • make ejbSelect not abstract
    • make ejbSelect throw FinderException
    • make Business,create,finder methods and method implementations from SessionBean/EntityBean/MessageDrivenBean interfaces not throw RemoteException
    • make static field final